package cn.wolfcode.crm.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;


@Getter
@Setter
public class Notice {
    private Long id;

    private Employee employee;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date pubdate;

    private Long readId;
    //公告标题
    private String title;
    //公告内容
    private String content;
    public String getJson(){
        HashMap map = new HashMap();
        map.put("id",id);
        if (employee!=null){
            map.put("employeeId", employee.getId());
        }
        map.put("pubdate",pubdate);
        map.put("title",title);
        map.put("content",content);
        //不能直接传this进去,会出现死循环
        return JSON.toJSONString(map);
    }

    public String getRead(){
        if (readId!=null){
            return "已读";
        }else {
            return "未读";
        }
    }
}